package com.aifund.app.controller;
import com.aifund.app.entity.form.login.LoginByPhoneForm;
import com.aifund.app.entity.vo.LoginVo;
import com.aifund.app.service.UserService;
import com.aifund.common.result.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录
 */
@RestController
@RequestMapping("/api/login")
@Api(tags = "登录")
public class LoginController {

    @Autowired
    UserService userService;

    /**
     * 通过手机号登录
     * @param form
     * @return
     */
    @ApiOperation("通过手机号登录")
    @PostMapping("/loginByPhone")
    public ResultBody<LoginVo> loginByPhone(@RequestBody @Validated LoginByPhoneForm form){
        return userService.loginByPhoneAndPwd(form.getPhone(), form.getPassword());
    }


}
